package com.caac.core.config;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Junction;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright caac 2006</p>
 * <p>Company: caac</p>
 * @author <a href="mailto:project@caac.com.cn">Project Group</a>
 * @version 1.0
 */

public class QueryClass extends Conf {
    private List list = new ArrayList();

    public void addChild(DmProperty dp) {
        list.add(dp);
    }

    public void init(Object bean, Map aliasMap, Map propMap) {
        for (int i = 0; i < list.size(); i++) {
            DmProperty dp = (DmProperty) list.get(i);
            dp.init(bean, aliasMap, propMap);
        }
    }

    public void addCriterion(Junction junction, Map propMap) {
        for (int i = 0; i < list.size(); i++) {
            DmProperty dp = (DmProperty) list.get(i);
            Criterion criterion = dp.getCriterion(propMap);
            if (criterion != null) {
                junction.add(criterion);
            }
        }
    }
}
